//
//  TTNavigationBarSaver.m
//  Tint
//
//  Created by Kevin Wu on 2/27/12.
//  Copyright (c) 2012 Telligenty. All rights reserved.
//

#import "TTNavigationBarSaver.h"

@implementation TTNavigationBarSaver

TTSynthesizeSingleton(TTNavigationBarSaver);


#pragma mark - Public

- (void)pushNavigationBar:(UINavigationBar *)navigationBar {
    TTNavigationBarSaverItem *item = [TTNavigationBarSaverItem make];
    item.tintColor = navigationBar.tintColor;
    item.transluceent = navigationBar.translucent;
    item.barStyle = navigationBar.barStyle;
    [_appearances push:item];
}

- (void)popNavigationBar:(UINavigationBar *)navigationBar {
    TTNavigationBarSaverItem *item = [_appearances pop];
    if (item) {
        [navigationBar setTintColor:item.tintColor];
        [navigationBar setTranslucent:item.transluceent];
        [navigationBar setBarStyle:item.barStyle];
    }
}

@end



@implementation TTNavigationBarSaverItem
@synthesize tintColor = _tintColor;
@synthesize transluceent = _transluceent;
@synthesize barStyle = _barStyle;
- (void)dealloc {
    TTRelease(_tintColor);
    [super dealloc];
}
@end
